<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActiveScaffold::Actions::Core</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActiveScaffold::Actions::Core</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/active_scaffold/lib/actions/core_rb.html">
                vendor/plugins/active_scaffold/lib/actions/core.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000337">accepts?</a>&nbsp;&nbsp;
      <a href="#M000335">authorized_for?</a>&nbsp;&nbsp;
      <a href="#M000336">clear_flashes</a>&nbsp;&nbsp;
      <a href="#M000343">conditions_for_collection</a>&nbsp;&nbsp;
      <a href="#M000345">conditions_from_params</a>&nbsp;&nbsp;
      <a href="#M000334">included</a>&nbsp;&nbsp;
      <a href="#M000344">joins_for_collection</a>&nbsp;&nbsp;
      <a href="#M000339">response_object</a>&nbsp;&nbsp;
      <a href="#M000338">response_status</a>&nbsp;&nbsp;
      <a href="#M000342">return_to_main</a>&nbsp;&nbsp;
      <a href="#M000341">successful=</a>&nbsp;&nbsp;
      <a href="#M000340">successful?</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000334" class="method-detail">
        <a name="M000334"></a>

        <div class="method-heading">
          <a href="#M000334" class="method-signature">
          <span class="method-name">included</span><span class="method-args">(base)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000334-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000334-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 3</span>
3:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">included</span>(<span class="ruby-identifier">base</span>)
4:       <span class="ruby-identifier">base</span>.<span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
5:         <span class="ruby-identifier">after_filter</span> <span class="ruby-identifier">:clear_flashes</span>
6:       <span class="ruby-keyword kw">end</span>
7:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000337" class="method-detail">
        <a name="M000337"></a>

        <div class="method-heading">
          <a href="#M000337" class="method-signature">
          <span class="method-name">accepts?</span><span class="method-args">(*types)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns true if the client accepts one of the MIME types passed to it ex:
<a href="Core.html#M000337">accepts?</a> :html, :xml
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000337-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000337-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 25</span>
25:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">accepts?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">types</span>)
26:       <span class="ruby-keyword kw">for</span> <span class="ruby-identifier">priority</span> <span class="ruby-keyword kw">in</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">accepts</span>.<span class="ruby-identifier">compact</span>
27:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">priority</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Mime</span><span class="ruby-operator">::</span><span class="ruby-constant">ALL</span>
28:           <span class="ruby-comment cmt"># Because IE always sends */* in the accepts header and we assume</span>
29:           <span class="ruby-comment cmt"># that if you really wanted XML or something else you would say so</span>
30:           <span class="ruby-comment cmt"># explicitly, we will assume */* to only ask for :html</span>
31:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">types</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:html</span>)
32:         <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">types</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">priority</span>.<span class="ruby-identifier">to_sym</span>)
33:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
34:         <span class="ruby-keyword kw">end</span>
35:       <span class="ruby-keyword kw">end</span>
36:       <span class="ruby-keyword kw">false</span>
37:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000335" class="method-detail">
        <a name="M000335"></a>

        <div class="method-heading">
          <a href="#M000335" class="method-signature">
          <span class="method-name">authorized_for?</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000335-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000335-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 11</span>
11:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">authorized_for?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
12:       <span class="ruby-identifier">active_scaffold_config</span>.<span class="ruby-identifier">model</span>.<span class="ruby-identifier">authorized_for?</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
13:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000336" class="method-detail">
        <a name="M000336"></a>

        <div class="method-heading">
          <a href="#M000336" class="method-signature">
          <span class="method-name">clear_flashes</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000336-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000336-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 15</span>
15:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_flashes</span>
16:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">xhr?</span>
17:         <span class="ruby-identifier">flash</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">flash_key</span><span class="ruby-operator">|</span>
18:           <span class="ruby-identifier">flash</span>[<span class="ruby-identifier">flash_key</span>] = <span class="ruby-keyword kw">nil</span>
19:         <span class="ruby-keyword kw">end</span>
20:       <span class="ruby-keyword kw">end</span>
21:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000343" class="method-detail">
        <a name="M000343"></a>

        <div class="method-heading">
          <a href="#M000343" class="method-signature">
          <span class="method-name">conditions_for_collection</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Override this method on your controller to define conditions to be used
when querying a recordset (e.g. for <a href="List.html">List</a>). The
return of this method should be any format compatible with the :conditions
clause of <a
href="../../ActiveRecord/Base.html">ActiveRecord::Base</a>&#8216;s find.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000343-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000343-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 68</span>
68:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">conditions_for_collection</span>
69:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000345" class="method-detail">
        <a name="M000345"></a>

        <div class="method-heading">
          <a href="#M000345" class="method-signature">
          <span class="method-name">conditions_from_params</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Builds search conditions by search params for column names. This allows
urls like &quot;contacts/list?company_id=5&quot;.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000345-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000345-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 74</span>
74:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">conditions_from_params</span>
75:       <span class="ruby-identifier">conditions</span> = <span class="ruby-keyword kw">nil</span>
76:       <span class="ruby-identifier">params</span>.<span class="ruby-identifier">reject</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">:controller</span>, <span class="ruby-identifier">:action</span>, <span class="ruby-identifier">:id</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_sym</span>)}.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
77:         <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">active_scaffold_config</span>.<span class="ruby-identifier">model</span>.<span class="ruby-identifier">column_names</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">key</span>)
78:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
79:           <span class="ruby-identifier">conditions</span> = <span class="ruby-identifier">merge_conditions</span>(<span class="ruby-identifier">conditions</span>, [<span class="ruby-node">&quot;#{active_scaffold_config.model.table_name}.#{key.to_s} in (?)&quot;</span>, <span class="ruby-identifier">value</span>])
80:         <span class="ruby-keyword kw">else</span>
81:           <span class="ruby-identifier">conditions</span> = <span class="ruby-identifier">merge_conditions</span>(<span class="ruby-identifier">conditions</span>, [<span class="ruby-node">&quot;#{active_scaffold_config.model.table_name}.#{key.to_s} = ?&quot;</span>, <span class="ruby-identifier">value</span>])
82:         <span class="ruby-keyword kw">end</span>
83:       <span class="ruby-keyword kw">end</span>
84:       <span class="ruby-identifier">conditions</span>
85:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000344" class="method-detail">
        <a name="M000344"></a>

        <div class="method-heading">
          <a href="#M000344" class="method-signature">
          <span class="method-name">joins_for_collection</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000344-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000344-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 70</span>
70:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">joins_for_collection</span>
71:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000339" class="method-detail">
        <a name="M000339"></a>

        <div class="method-heading">
          <a href="#M000339" class="method-signature">
          <span class="method-name">response_object</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
API response object that will be converted to XML/YAML/JSON using to_xxx
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000339-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000339-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 44</span>
44:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response_object</span>
45:       <span class="ruby-ivar">@response_object</span> = <span class="ruby-identifier">successful?</span> <span class="ruby-value">? </span>(<span class="ruby-ivar">@record</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@records</span>) <span class="ruby-operator">:</span> <span class="ruby-ivar">@record</span>.<span class="ruby-identifier">errors</span>
46:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000338" class="method-detail">
        <a name="M000338"></a>

        <div class="method-heading">
          <a href="#M000338" class="method-signature">
          <span class="method-name">response_status</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000338-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000338-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 39</span>
39:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">response_status</span>
40:       <span class="ruby-identifier">successful?</span> <span class="ruby-value">? </span><span class="ruby-value">200</span> <span class="ruby-operator">:</span> <span class="ruby-value">500</span>
41:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000342" class="method-detail">
        <a name="M000342"></a>

        <div class="method-heading">
          <a href="#M000342" class="method-signature">
          <span class="method-name">return_to_main</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Redirect to the main page (override if the <a
href="../../ActiveScaffold.html">ActiveScaffold</a> is used as a component
on another controllers page) for Javascript degradation
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000342-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000342-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 63</span>
63:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">return_to_main</span>
64:       <span class="ruby-identifier">redirect_to</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:action</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">&quot;index&quot;</span>)
65:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000341" class="method-detail">
        <a name="M000341"></a>

        <div class="method-heading">
          <a href="#M000341" class="method-signature">
          <span class="method-name">successful=</span><span class="method-args">(val)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000341-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000341-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 58</span>
58:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">successful=</span>(<span class="ruby-identifier">val</span>)
59:       <span class="ruby-ivar">@successful</span> = (<span class="ruby-identifier">val</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
60:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000340" class="method-detail">
        <a name="M000340"></a>

        <div class="method-heading">
          <a href="#M000340" class="method-signature">
          <span class="method-name">successful?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Success is the existence of certain variables and the absence of errors
(when applicable). Success can also be defined.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000340-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000340-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/actions/core.rb, line 50</span>
50:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">successful?</span>
51:       <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@successful</span>.<span class="ruby-identifier">nil?</span>
52:         <span class="ruby-ivar">@records</span> <span class="ruby-keyword kw">or</span> (<span class="ruby-ivar">@record</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@record</span>.<span class="ruby-identifier">errors</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@record</span>.<span class="ruby-identifier">no_errors_in_associated?</span>)
53:       <span class="ruby-keyword kw">else</span>
54:         <span class="ruby-ivar">@successful</span>
55:       <span class="ruby-keyword kw">end</span>
56:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>